package WrittenExamination;

import java.util.Scanner;

public class day2 {
    /**
     * 最长连续顺序子序列
     * @param args
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int [] arr = new int[n+1];//防止最后多出一个数是单个成一队
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        int count = 0;
        int i = 1;
        while (i<arr.length){
            if(arr[i-1] < arr[i]){
                while(i<arr.length && arr[i-1] < arr[i]){
                    i++;
                }
                count++;
                i++;
            }else if(arr[i-1] == arr[i]){
                i++;
            }else{
                while(i<arr.length && arr[i-1] > arr[i]){
                    i++;
                }
                count++;
                i++;
            }
        }
        System.out.println(count);
    }
}
